package com.freemalll.merchant.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.freemalll.common.core.annotation.ResultInterceptor;
import com.freemalll.merchant.domain.dto.MerCooperateHistoryPageDto;
import com.freemalll.merchant.domain.dto.merchantReport.MerchantAccountEditDto;
import com.freemalll.merchant.domain.dto.merchantReport.MerchantRateEditDto;
import com.freemalll.merchant.domain.dto.merchantReport.MerchantReportPageDto;
import com.freemalll.merchant.domain.entity.MerCooperateHistory;
import com.freemalll.merchant.domain.entity.MerMerchantAuditEditLog;
import com.freemalll.merchant.domain.vo.merchantReport.MerchantBusinessParametersVo;
import com.freemalll.merchant.domain.vo.merchantReport.MerchantPerformanceVo;
import com.freemalll.merchant.domain.vo.merchantReport.MerchantReportPageVo;
import com.freemalll.merchant.domain.vo.merchantReport.MerchantReportVo;
import com.freemalll.merchant.service.MerCooperateHistoryService;
import com.freemalll.merchant.service.MerchantReportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Tag(name = "商户管理：商户报告")
@RestController
@RequestMapping("/merchant-manage-report")
@ResultInterceptor
@AllArgsConstructor
public class MerchantReportController {

    private final MerchantReportService merchantReportService;
    private final MerCooperateHistoryService merCooperateHistoryService;

    @PostMapping("/page")
    @Operation(summary = "分页")
    public Page<MerchantReportPageVo> page(@RequestBody MerchantReportPageDto dto) {
        return merchantReportService.page(dto);
    }

    @GetMapping("/getMerchantBasicInfo")
    @Operation(summary = "获取商户基础信息")
    public MerchantReportVo getMerchantBasicInfo(@RequestParam(value = "merId") String merId) {
        return merchantReportService.getMerchantBasicInfo(merId);
    }

    @GetMapping("/getMerchantBusinessParameters")
    @Operation(summary = "获取商户业务参数")
    public MerchantBusinessParametersVo getMerchantBusinessParameters(@RequestParam(value = "merId") String merId) {
        return merchantReportService.getMerchantBusinessParameters(merId);
    }

    @GetMapping("/getMerchantPerformance")
    @Operation(summary = "获取商户业务表现")
    public MerchantPerformanceVo getMerchantPerformance(@RequestParam(value = "merId") String merId, @RequestParam(value = "tabType") String tabType) {
        return merchantReportService.getMerchantPerformance(merId, tabType);
    }

    @PostMapping("/rateActivationStatus")
    @Operation(summary = "费率启用状态编辑")
    public void rateActivationStatus(@RequestBody @Valid MerchantRateEditDto dto) {
        merchantReportService.rateActivationStatus(dto);
    }

    @PostMapping("/accountEnableStatusEdit")
    @Operation(summary = "银行账户启用状态编辑")
    public void accountEnableStatusEdit(@RequestBody @Valid MerchantAccountEditDto dto) {
        merchantReportService.accountEnableStatusEdit(dto);
    }

    @GetMapping("/getChangeRecord")
    @Operation(summary = "获取收款户变更记录 changeType传 RECIPIENT_INFO 收款户日志 传CAPITAL_ORDER 资方顺位日志")
    public List<MerMerchantAuditEditLog> getChangeRecord(@RequestParam(value = "merId") String merId, @RequestParam(value = "changeType") String changeType) {
        return merchantReportService.getChangeRecord(merId, changeType);
    }

    @Operation(summary = "合作历程列表  merId必传")
    @PostMapping("/cooperate/history/all")
    public List<MerCooperateHistory> listSearch(@RequestBody MerCooperateHistoryPageDto search) {
        return merCooperateHistoryService.listSearch(search);
    }


}
